package com.sijiao.difflog.service.impl;

import com.sijiao.difflog.entity.LogResult;
import com.sijiao.difflog.entity.LogTask;
import com.sijiao.difflog.service.IReporterService;

import java.util.concurrent.Future;
import java.util.concurrent.ThreadPoolExecutor;

public class ReporterServiceImpl implements IReporterService {
    private final ThreadPoolExecutor threadPoolExecutor;

    public ReporterServiceImpl(ThreadPoolExecutor threadPoolExecutor) {
        this.threadPoolExecutor = threadPoolExecutor;
    }

    @Override
    public Future<LogResult> report(String bizName, Object original, Object result) {
        LogTask logTask = new LogTask(original, result, bizName);
        System.out.println(logTask);
        return threadPoolExecutor.submit(logTask);
    }


}
